Skip to content

[TASK] Add PHPStan extension to allow assertions#1594

Merged
oliverklee merged 1 commit into
mainfrom
task/allow-assert-instanceof
Jun 17, 2026
Merged

[TASK] Add PHPStan extension to allow assertions#1594
oliverklee merged 1 commit into
mainfrom
task/allow-assert-instanceof

Conversation

@JakeQZ

@JakeQZ JakeQZ commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator

Suppress warnings for assert()s that, according to the DocBlock, can never fail, but in reality could, due to programmer error, since the DocBlock types are not enforced by PHP.

This allows us to restore treatPhpDocTypesAsCertain:true for stricter static analysis, whilst also using assertions for runtime checks in a development environment, without cluttering up the code with @phpstan-ignore comments.

The change parallels MyIntervals/emogrifier#1624. It may be possible in future to move the extension to a separate package.

@JakeQZ JakeQZ requested a review from oliverklee June 16, 2026 20:06
@JakeQZ JakeQZ self-assigned this Jun 16, 2026
@JakeQZ JakeQZ added enhancement testing PRs/issues adding additional tests only, or primarily testing-focused developer-specific Issues that only affect maintainers, contributors, and people submitting PRs labels Jun 16, 2026
@JakeQZ JakeQZ force-pushed the task/allow-assert-instanceof branch from 7e5ccfa to 6f316fa Compare June 16, 2026 20:07
@coveralls

coveralls commented Jun 16, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 72.604% (-0.7%) from 73.3% — task/allow-assert-instanceof into main

Suppress warnings for `assert()`s that, according to the DocBlock, can never
fail, but in reality could, due to programmer error, since the DocBlock types
are not enforced by PHP.

This allows us to restore `treatPhpDocTypesAsCertain:true` for stricter static
analysis, whilst also using assertions for runtime checks in a development
environment, without cluttering up the code with `@phpstan-ignore` comments.

The change parallels MyIntervals/emogrifier#1624.
It may be possible in future to move the extension to a separate package.
@JakeQZ JakeQZ force-pushed the task/allow-assert-instanceof branch from 6f316fa to 1ae8385 Compare June 16, 2026 20:19
@oliverklee oliverklee merged commit 1dd6b84 into main Jun 17, 2026
45 of 47 checks passed
@oliverklee oliverklee deleted the task/allow-assert-instanceof branch June 17, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

developer-specific Issues that only affect maintainers, contributors, and people submitting PRs enhancement testing PRs/issues adding additional tests only, or primarily testing-focused

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants